<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
	<div ng-controller="resourceController">
		<div ng-path></div>

		<div>
			<table class="table table-hover">
				<thead>
					<tr>
						<td width="20%">名称</td>
						<td width="25%">URL</td>
						<td width="15%">图标</td>
						<td width="15%">权限点</td>
						<td width="5%">顺序</td>
						<td width="20%">操作</td>
					</tr>
				</thead>
				<tbody>
					<tr ng-repeat="res in rm.resourceList" ng-show="!res.parIsClosed">
						<td class="blank-{{res.depth}}"><span
							style="margin-right: 22px;" ng-show="res.resourceList == null"></span>
							<span class="glyphicon tree-icon"
							ng-click="res.isClosed = !res.isClosed;rm.resSwith(res)"
							ng-show="res.resourceList != null"
							ng-class="res.isClosed?'glyphicon-plus':'glyphicon-minus'"></span>{{res.name}}</td>
						<td>{{res.url}}</td>
						<td>{{res.icon}}</td>
						<td>{{res.permission}}</td>
						<td>{{res.orderid}}</td>
						<td><shiro:hasPermission name="resource:edit">
								<button type="button" class="btn btn-primary btn-xs"
									data-toggle="modal" data-target="#resourceDetail"
									ng-click="rm.edit(res)" ng-show="res.id != 1">编辑</button>
							</shiro:hasPermission> <shiro:hasPermission name="resource:add">
								<button type="button" class="btn btn-info btn-xs"
									data-toggle="modal" data-target="#resourceDetail"
									ng-click="rm.add(res)">添加下级菜单</button>
							</shiro:hasPermission> <shiro:hasPermission name="resource:delete">
								<button type="button" class="btn btn-danger btn-xs"
									ng-click="rm.del(res)" ng-show="res.id != 1">删除</button>
							</shiro:hasPermission></td>
					</tr>
				</tbody>
			</table>
		</div>

		<!-- 添加修改 -->
		<div class="modal fade" role="dialog" id="resourceDetail">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button>
						<h4 class="modal-title">{{rm.title}}</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form" name="resForm">
							<input type="hidden" ng-model="rm.resource.id" />
							<div class="form-group form-group-sm" ng-show="!rm.isEdit">
								<label class="col-sm-4 control-label">上级菜单</label>
								<div class="col-sm-6">
									<input type="text" class="form-control"
										ng-disabled="!rm.isEdit" ng-model="rm.currentRes.name">
								</div>
							</div>
							<div class="form-group form-group-sm">
								<label class="col-sm-4 control-label">菜单名称</label>
								<div class="col-sm-6">
									<input type="text" class="form-control"
										ng-model="rm.resource.name" required="" />
								</div>
							</div>
							<div class="form-group form-group-sm">
								<label class="col-sm-4 control-label">图标</label>
								<div class="col-sm-6">
									<input type="text" class="form-control"
										ng-model="rm.resource.icon" />
								</div>
							</div>
							<div class="form-group form-group-sm">
								<label class="col-sm-4 control-label">URL</label>
								<div class="col-sm-6">
									<input type="text" class="form-control"
										ng-model="rm.resource.url" placeholder="以admin开始" />
								</div>
							</div>
							<div class="form-group form-group-sm">
								<label class="col-sm-4 control-label">权限点</label>
								<div class="col-sm-6">
									<input type="text" class="form-control" namg="permission"
										required="" ng-model="rm.resource.permission"
										placeholder="如:user:view" />
								</div>
							</div>
							<div class="form-group form-group-sm">
								<label class="col-sm-4 control-label">排序</label>
								<div class="col-sm-6">
									<input type="number" class="form-control"
										ng-model="rm.resource.orderid" />
								</div>
							</div>

							<div class="form-group"
								ng-show="resForm.$invalid && rm.showError">
								<div class="col-sm-6 col-sm-offset-4">
									<div
										class="alert alert-danger alert-dismissible fade in custom-alert"
										role="alert">
										<ul>
											<li ng-show="resForm.name.$error.required">菜单名不能为空！</li>
											<li ng-show="resForm.permission.$error.required">权限点不能为空！</li>
										</ul>
									</div>
								</div>
							</div>
							<div class="form-group" ng-show="rm.showMessage">
								<div class="col-sm-6 col-sm-offset-4">
									<div class="alert alert-dismissible fade in custom-alert"
										role="alert"
										ng-class="rm.result==0?'alert-danger':'alert-success'">
										{{rm.message}}</div>
								</div>
							</div>
						</form>
					</div>
					<div class="modal-footer">
						<button type="submit" class="btn btn-primary"
							ng-click="rm.addOrEdit(resForm)">提交</button>
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					</div>
				</div>
			</div>
		</div>

	</div>
</body>
</html>